package Java_2_1;


import java.util.Scanner;

public class Java_2_1_6 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入一个四位数:");
        int a=sc.nextInt();
        if(a>=1000 && a<=9999) {
            int b=a%1000;
            int b1=(a-b)/1000;
            int c=b%100;
            int c1=(b-c)/100;
            int d=c%10;
            int d1=(c-d)/10;
            System.out.println("个位:"+d+"，十位:"+d1+"，百位:"+c1+"，千位:"+b1+"和为:"+(b1+c1+d1+d));
        }
        else {
            System.out.println("输入有误");

        }
    }
}
